package view.diaLogView;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.example.administrator.text.R;

/**
 * Created by liuxiaobin on 2017/11/8
 * 封装一个比较常用的Dialog
 *一种是带图的提示
 * 另一种是 取消 确定类型的
 * 新手指导
 */

public class CommomDialog extends Dialog implements View.OnClickListener{
    private Context mContext;
    private ImageView fork;
    private Button ok;
    public CommomDialog(Context context) {
        super(context,R.style.upoad_dialog);
        this.mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_commom);
        setCanceledOnTouchOutside(true);
        init();
    }

    private void init(){
        fork = (ImageView) findViewById(R.id.dialog_commom_fork);
        ok = (Button) findViewById(R.id.dialog_commom_ok);
        fork.setOnClickListener(this);
        ok.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.dialog_commom_fork:
                this.dismiss();
                break;
            case R.id.dialog_commom_ok:
                this.dismiss();
                break;
        }
    }

    public interface OnCloseListener{
        void onClick(Dialog dialog, boolean confirm);
    }
}
